Skip to content

Check for nil host before match?.#841

Open
benubois wants to merge 1 commit into
httprb:mainfrom
benubois:nil_host
Open

Check for nil host before match?.#841
benubois wants to merge 1 commit into
httprb:mainfrom
benubois:nil_host

Conversation

@benubois

Copy link
Copy Markdown
Contributor

When host is nil, I get a NoMethodError: undefined method 'match?' for nil error instead of a RequestError.

Thanks!

@ixti

ixti commented Jun 24, 2026

Copy link
Copy Markdown
Member

Thank you!

@ixti

ixti commented Jun 24, 2026

Copy link
Copy Markdown
Member

After some thinking. While we're at this, we should probably enrich that method in general. According (if I read it correct) to RFC 9110:

Host = uri-host [ ":" port ]; Section 4

uri-host      = <host, see [URI], Section 3.2.2>
port          = <port, see [URI], Section 3.2.3>

Host part is mandatory. And, either way, I think it's at least mandatory in case of "default" ))

So, I think:

  • ":123" (empty host, different port, as in https://:123/foobar) MUST be invalid for default host header
  • "" (empty host, no whitespaces, same port, as in https:///foobar) MUST be invalid as well

cc: @sferik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants